home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-09-28 | 2.6 KB | 107 lines |
- /*
- * QuickTime for Java SDK Sample Code
-
- Usage subject to restrictions in SDK License Agreement
- * Copyright: © 1996-1999 Apple Computer, Inc.
-
- */
- import java.awt.*;
- import java.awt.event.*;
-
- import quicktime.qd.*;
- import quicktime.*;
- import quicktime.util.*;
-
-
- import quicktime.io.*;
- import quicktime.std.StdQTConstants;
- import quicktime.std.sg.*;
-
- import quicktime.app.sg.SGDrawer;
- import quicktime.std.movies.*;
- import quicktime.app.display.QTCanvas;
-
- public class SGCapture extends Frame implements WindowListener, StdQTConstants, Errors {
-
- static final int kWidth = 320;
- static final int kHeight = 240;
-
- public static void main (String args[]) {
- try {
- SGCapture pm = new SGCapture("QT in Java");
- pm.show();
- pm.toFront();
- } catch (Exception e) {
- e.printStackTrace();
- QTSession.close();
- }
- }
-
- SGCapture (String title) {
- super (title);
- try {
- QTSession.open();
- myQTCanvas = new QTCanvas(QTCanvas.kPerformanceResize, 0.5F, 0.5F);
- myQTCanvas.setMaximumSize (new Dimension (640, 480));
-
- add ("Center", myQTCanvas);
- addNotify();
- Insets insets = getInsets();
- setBounds (0, 0, (insets.left + insets.right + kWidth), (insets.top + insets.bottom + kHeight));
-
- addWindowListener(this);
- } catch (Exception ee) {
- ee.printStackTrace();
- QTSession.close();
- }
- }
-
- private QTCanvas myQTCanvas;
- private SGSoundChannel mAudio;
- private SGDrawer mDrawable;
- private QTFile mFile;
- private Movie mMovie;
-
- public void windowClosing (WindowEvent e) {
- QTSession.close();
- dispose();
- }
-
- public void windowIconified (WindowEvent e) {
- }
-
- public void windowDeiconified (WindowEvent e) {
- }
-
- public void windowClosed (WindowEvent e) {
- System.exit(0);
- }
-
- public void windowOpened (WindowEvent e) {
- try{
- SequenceGrabber mGrabber = new SequenceGrabber();
-
- SGVideoChannel mVideo = new SGVideoChannel(mGrabber);
-
- mVideo.settingsDialog ();
-
- mVideo.setBounds (new QDRect(kWidth, kHeight));
- mVideo.setUsage (seqGrabPreview | seqGrabRecord | seqGrabPlayDuringRecord); // seqGrabRecord
-
- mAudio = new SGSoundChannel(mGrabber);
- mAudio.setUsage (seqGrabPreview | seqGrabRecord | seqGrabPlayDuringRecord); // seqGrabRecord
- mAudio.setVolume (2);
-
- mDrawable = new SGDrawer(mVideo);
- myQTCanvas.setClient(mDrawable,true);
- mGrabber.prepare(true,false);
- mGrabber.startPreview();
- } catch (Exception ee) {
- ee.printStackTrace();
- QTSession.close();
- }
- }
- public void windowActivated (WindowEvent e) {}
- public void windowDeactivated (WindowEvent e) {}
- }
-